package com.nervenets.web.controller.handler.user.user;


import com.nervenets.web.controller.handler.Handler;
import com.nervenets.web.controller.handler.common.TokenParams;
import com.nervenets.web.enumeration.WealthType;

import javax.servlet.http.HttpServletRequest;

public class UserSurplusHandler extends Handler<UserSurplusParams> {
    @Override
    public String handle(UserSurplusParams params, HttpServletRequest request) throws Exception {
        WealthType wealthType = WealthType.money;
        if (null != params.getWealthType()) wealthType = params.getWealthType();
        final long surplus = userDao.getSurplus(params.getUserId(), wealthType);
        return successMessage(surplus);
    }

    @Override
    public String result() throws Exception {
        return successMessage();
    }
}
